package org.dxy.domain.event.equipment;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Value;
import org.dxy.domain.event.AggregateTypeEnum;
import org.dxy.domain.event.DomainEvent;

import java.time.LocalDateTime;

/**
 * 设备故障已检测事件
 * @author dxy
 * @createTime 2025/6/15 14:45
 */
@Value
@Builder
@AllArgsConstructor
public class EquipmentFaultDetectedEvent implements DomainEvent {
    /**
     * 设备 ID
     */
    Long equipmentId;

    /**
     * 故障类型，如 OVERHEAT, VOLTAGE_DROP, HARDWARE_FAILURE 等
     */
    String faultType;

    /**
     * 故障描述（可选）
     */
    String description;

    /**
     * 故障检测时间
     */
    @Builder.Default
    LocalDateTime detectedTime = LocalDateTime.now();
    
    @Override
    public Long aggregateId() {
        return equipmentId;
    }
    
    @Override
    public String aggregateType() {
        return AggregateTypeEnum.EQUIPMENT.getKey();
    }
    
    @Override
    public String eventType() {
        return EquipmentEventTypeEnum.FAULT_DETECTED.getKey();
    }
}